package com.herui.ota.controller;

import com.herui.ota.config.ControllerNames;
import com.herui.ota.pojo.vo.DeviceAreaCountVo;
import com.herui.ota.pojo.form.DeviceNewDailyFilterForm;
import com.herui.ota.pojo.vo.DeviceNewDailyStaticVo;
import com.herui.ota.service.DeviceNewDailyService;
import com.mlnx.common.annotations.NeedLogin;
import com.mlnx.common.entity.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.shan.spring.base.BaseController;
import org.shan.spring.base.annotations.SysLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@Api(value = ControllerNames.DeviceNewDailyName + "接口", tags = {ControllerNames.DeviceNewDailyName + "接口"})
@SysLog(title = ControllerNames.DeviceNewDailyName)
@RestController
@RequestMapping("/devicenewdaily")
public class DeviceNewDailyController extends BaseController {
    @Autowired
    private DeviceNewDailyService service;

    @NeedLogin
    @ApiOperation(
            value = "获取当天新增总数",
            notes = ""
    )
    @GetMapping({"/currentDayTotalCount"})
    public ResponseData<Integer> getCurrentDayTotalCount() {
        return this.result(service.getCurrentDayTotalCount());
    }

    @NeedLogin
    @ApiOperation(
            value = "获取本周新增总数",
            notes = ""
    )
    @GetMapping({"/week"})
    public ResponseData<DeviceNewDailyStaticVo> getWeekDeviceNewDailyStaticVos(DeviceNewDailyFilterForm filter) {
        return this.result(service.getWeekDeviceNewDailyStaticVos(filter));
    }

    @NeedLogin
    @ApiOperation(
            value = "获取本月新增总数",
            notes = ""
    )
    @GetMapping({"/month"})
    public ResponseData<DeviceNewDailyStaticVo> getMonthDeviceNewDailyStaticVos(DeviceNewDailyFilterForm filter) {
        return this.result(service.getMonthDeviceNewDailyStaticVos(filter));
    }

    @NeedLogin
    @ApiOperation(
            value = "根据起始结束时间获取每天新增总数",
            notes = ""
    )
    @GetMapping({"/list"})
    public ResponseData<DeviceNewDailyStaticVo> list(Date start, Date end, DeviceNewDailyFilterForm filter) {
        return this.result(service.getDeviceNewDailyStaticVos(start, end, filter));
    }

    @NeedLogin
    @ApiOperation(
            value = "获取区域数量统计",
            notes = ""
    )
    @GetMapping({"/areacount"})
    public ResponseData<DeviceAreaCountVo> getDeviceAreaCountVos() {
        return this.result(service.getDeviceAreaCountVos());
    }
}
